package br.com.ozsolucoes.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;

@Entity
@NamedQueries({
	@NamedQuery(name = "Contas.consultarContasClienteStatus" , query = "select c from Contas c where c.statusPagamento =:status and c.servico.cliente.id =:idCliente"),
	@NamedQuery(name = "Contas.consultarContasClienteStatusServico" , query = "select c from Contas c where c.statusPagamento =:status and c.servico.cliente.id =:idCliente and c.servico.id = :idServico and c.servico.statusServico = :statusServico"),
	@NamedQuery(name = "Contas.consultarTodasContasCliente" , query = "select c from Contas c where c.servico.cliente.id =:idCliente"),
	@NamedQuery(name = "Contas.consultarTodasContas" , query = "select c from Contas c"),
	@NamedQuery(name = "Contas.consultarContasClienteStatusPeriodo" , query = "select c from Contas c where c.statusPagamento =:status and c.servico.cliente.id =:idCliente and c.dataVencimento between :dataInicial and :dataFinal"),
	@NamedQuery(name = "Contas.consultarContasStatusPeriodo" , query = "select c from Contas c where c.statusPagamento =:status and c.dataVencimento between :dataInicial and :dataFinal"),
	@NamedQuery(name = "Contas.consultarContasStatus" , query = "select c from Contas c where c.statusPagamento =:status"),
	@NamedQuery(name = "Contas.consultarContaClientePorServicoPeriodo" , query = "select c from Contas c where c.servico.cliente.id =:idCliente and c.dataVencimento between :dataInicial and :dataFinal"),
	@NamedQuery(name = "Contas.consultarContasClientePeriodo" , query = "select c from Contas c where c.servico.cliente.id =:idCliente and c.dataVencimento between :dataInicial and :dataFinal"),
	@NamedQuery(name = "Contas.consultarContasPeriodo" , query = "select c from Contas c where c.dataVencimento between :dataInicial and :dataFinal"),
	@NamedQuery(name = "Contas.consultarContasComComprovantesStatus" , query = "select c from Contas c where c.servico.cliente.id =:idCliente and c.servico.id = :idServico and c.statusPagamento = :status and c.comprovante is not null"),
})
public class Contas implements Serializable {

	private static final long serialVersionUID = 5103632572936942083L;

	@Id
	@GeneratedValue
	private long id;

	private Double valor;

	private Date dataVencimento;

	private int statusPagamento;
	
	@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER, targetEntity = Documento.class)
	private Documento comprovante;
	
	@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER, targetEntity = Servico.class)
	private Servico servico;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public Date getDataVencimento() {
		return dataVencimento;
	}

	public void setDataVencimento(Date dataVencimento) {
		this.dataVencimento = dataVencimento;
	}

	public Servico getServico() {
		return servico;
	}

	public void setServico(Servico servico) {
		this.servico = servico;
	}

	public Double getValor() {
		return valor;
	}

	public void setValor(Double valor) {
		this.valor = valor;
	}

	public int getStatusPagamento() {
		return statusPagamento;
	}

	public void setStatusPagamento(int statusPagamento) {
		this.statusPagamento = statusPagamento;
	}

	public Documento getComprovante() {
		return comprovante;
	}

	public void setComprovante(Documento comprovante) {
		this.comprovante = comprovante;
	}

}
